package xuegao.study.mall.admin.controller;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xuegao.study.mall.admin.feign.OmsOrderReturnApplyClient;
import xuegao.study.mall.common.api.CommonPage;
import xuegao.study.mall.common.api.CommonResult;
import xuegao.study.mall.common.dto.OmsReturnApplyQueryParam;
import xuegao.study.mall.common.dto.OmsUpdateStatusParam;
import xuegao.study.mall.common.model.oms.OmsOrderReturnApply;

import java.util.List;

@RestController
@RequestMapping("/returnApply")
public class OmsOrderReturnApplyController {

    @Autowired
    private OmsOrderReturnApplyClient omsOrderReturnApplyClient;

    @ApiOperation("分页查询退货申请")
    @GetMapping(value = "/list")
    public CommonResult<CommonPage<OmsOrderReturnApply>> list(
            OmsReturnApplyQueryParam queryParam,
            @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
            @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
        return omsOrderReturnApplyClient.list(queryParam, pageSize, pageNum);
    }

    @ApiOperation("批量删除退货申请")
    @PostMapping(value = "/delete")
    public CommonResult delete(@RequestParam("ids") List<Long> ids) {
        return omsOrderReturnApplyClient.delete(ids);
    }

    @ApiOperation("获取退货申请详情")
    @GetMapping(value = "/{id}")
    public CommonResult getItem(@PathVariable Long id) {
        return omsOrderReturnApplyClient.getItem(id);
    }

    @ApiOperation("修改退货申请状态")
    @PostMapping(value = "/update/status/{id}")
    public CommonResult updateStatus(@PathVariable Long id, @RequestBody OmsUpdateStatusParam statusParam) {
        return omsOrderReturnApplyClient.updateStatus(id, statusParam);
    }
}
